var rp = require('request-promise');
const { target } = require('../utils/options');


const get = async () => {
    var options = {
        method: 'POSt',
        uri: `${ target }/users/getUsers`,
        qs: {},
        json: true // Automatically stringifies the body to JSON
    };
    let data = await rp(options);
    return data;
};

const update = async (parameter) => {
    var options = {
        method: 'POSt',
        uri: `${ target }/users/updateUsers`,
        qs: { },
        body: parameter,
        json: true // Automatically stringifies the body to JSON
    };
    let data = await rp(options);
    return data;
};

const del = async (_id) => {
    var options = {
        method: 'POSt',
        uri: `${ target }/users/deleteUsers`,
        qs: { },
        body: {_id},
        json: true // Automatically stringifies the body to JSON
    };
    let data = await rp(options);
    return data;
};

const addUser = async (parameter) => {
    var options = {
        method: 'POSt',
        uri: `${ target }/users/addUser`,
        qs: { },
        body: {parameter},
        json: true // Automatically stringifies the body to JSON
    };
    let data = await rp(options);
    return data;
};
const search = async (parameter) => {
    var options = {
        method: 'POSt',
        uri: `${ target }/users/searchUser`,
        qs: { },
        body: parameter,
        json: true // Automatically stringifies the body to JSON
    };
    let data = await rp(options);
    return data;
};

module.exports = { get ,update,del,addUser,search};